# Copyright (c) 2024, json_wang and contributors
# For license information, please see license.txt

import frappe
from frappe.model.document import Document


class CP_Issue_Bonus(Document):
	def on_submit(self):
		project_bonus_doc = frappe.get_doc("CP_Project_Bonus", self.project)
		for row in project_bonus_doc.items:
			for item in self.items:
				if row.name == item.source_name:
					row.paid = row.paid + item.paid
					row.unpaid = row.unpaid - item.paid
		project_bonus_doc.save()